<template>
  <div class="layui-tab-item">
    <div class="layui-card">
      <div
        class="layui-form layui-card-header layuiadmin-card-header-auto"
        style="padding: 15px 15px 0px 15px"
      >
        <div class="layui-row">
          <div class="layui-col-md3">
            <div class="layui-form-item">
              <label class="layui-form-label">流程分类</label>
              <div class="layui-input-block">
                <input
                  type="text"
                  v-model.trim="model.category"
                  placeholder="请选择流程分类"
                  class="layui-input"
                />
              </div>
            </div>
          </div>
        </div>
        <div class="layui-row">
          <div class="layui-col-md4">
            <div class="layui-form-item">
              <label class="layui-form-label">文件上传</label>
              <div class="layui-input-inline">
                <button class="layui-btn layui-btn-normal" id="uploadFile">
                  <i class="layui-icon layui-icon-upload"></i>点击选择上传文件
                </button>
              </div>
              <div class="layui-form-mid layui-word-aux">
                支持文件格式：zip、bar、bpmn、bpmn20.xml
              </div>
            </div>
          </div>
        </div>
        <div class="layui-row">
          <div class="layui-col-md3">
            <div class="layui-form-item">
              <div class="layui-input-block">
                <button class="layui-btn" id="submitFile">提交</button>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
export default {
  name: "DeployProcess",
  data: function () {
    return {
      model: {},
    };
  },
  mounted: function () {
    this.initLayui();
    this.fileupload();
  },
  methods: {
    fileupload: function () {
      var that = this;
      layui.use("upload", function () {
        var upload = layui.upload;
        var index = "";
        //执行实例
        var uploadInst = upload.render({
          elem: "#uploadFile", //绑定元素
          url: that.activitiProcess + "/deploy", //上传接口
          field: "files",
          data: that.model,
          accept: "file",
          exts: "zip|bar|bpmn|bpmn20.xml",
          auto: false,
          bindAction: "#submitFile",
          multiple: true,
          number: 10,
          before: function () {
            that.openLoading(function (index1) {
              index = index1;
            });
          },
          done: function (res) {
            //上传完毕回调
            that.closeLoading();
            if (res.code != "000000") {
              that.showMsg(res.msg, false);
            } else {
              that.openMsg(res.msg, true);
            }
          },
          error: function () {
            that.closeLoading();
          },
        });
      });
    },
  },
};
</script>